// ============================== 导入依赖 ============================== //

import CORE from '@/CORE'
import Client from '@api/equipment/api/AssetChangeAllocationApi'

import OneClass from '@api/equipment/model/ChangeDetailQueryReq'

const CLIENT = CORE.grpcCLIENT(Client)

// ============================== 导出远程接口 ============================== //

export default {
  // —————————————————————————————— 单项 —————————————————————————————— //

  validOne(one) {
    return one.id
  },
  async getOne({ id }, TIP = '查询详情') {
    const DTO = CORE.grpcDTO(OneClass, { changeId: id })
    const resp = await CORE.grpc(TIP, CLIENT, 'queryChangeAllocationDetail', DTO)
    return resp.content || {}
  },
  transOne(obj) {
    const record = obj.changeOperateDtoList || []
    record.forEach((item) => {
      if (item.operateType === 3) item.description = obj.allocationRemark
    })
    return obj
  },
}
